﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DoAn_BumTruong_DesignPattern.Controls
{
    public partial class MenuRight : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LaodData();
            }
        }
        Facades fcmenu = new Facades();
        private void LaodData()
        {
            RepeaterMenuCHa.DataSource = fcmenu.GetMenuRightTop("1").Where(mn => mn.ParentID == null);
            RepeaterMenuCHa.DataBind();
            string lbMenuID = Request.QueryString["MenuID"] ?? "1";
            foreach (RepeaterItem item in RepeaterMenuCHa.Items)
            {
                Repeater rpTerChildren = (Repeater)item.FindControl("RepeaterMenuCon");
                if (lbMenuID != "")
                {
                    int menuid = Convert.ToInt32(lbMenuID);
                    rpTerChildren.DataSource = fcmenu.GetMenuRightTop("1").Where(m => m.ParentID != null && m.ParentID == menuid);
                    rpTerChildren.DataBind();
                }
            }
        }
    }
}